#include <iostream>

using namespace std;

template <class T>
class Singleton {
	static T *instance_;
	Singleton() {}

public:
	static T const & instance() {
		//return m;	

		if(instance_ == NULL) {
			instance_ = new T;
		}
		return *instance_;
	}
};

template <class T> T * Singleton<T>::instance_ = NULL;

class A {
public :
	A() {};
	int m;
	void printTest() {
		cout << "test msg" << endl;
	}
};

typedef Singleton<A> singleA;

int main() {
	
	//A *t;
	//printTest();	
	//Singleton<A>::instance().printTest();
	//t.printTest();
	//t->printTest();
	A instance = Singleton<A>::instance();
	//A inst = singleA::instance();
	instance.printTest();
	//Singleton<A>::instance()->printTest();

	return 0;

}
